package generator.config;

import lombok.Data;
import lombok.experimental.Accessors;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
 * <p>
 *
 * </p>
 *
 * @author angel.bin@aliyun.com
 * @since 2020-10-05 13:49
 */
@Data
@Accessors(chain = true)
public class TemplateConfig {
    private static TemplateConfig templateConfig;

    static {
        try (InputStream in = TemplateConfig.class.getClassLoader().getResourceAsStream("template.properties")) {
            Properties properties = new Properties();
            properties.load(in);
            templateConfig = new TemplateConfig()
                    .setBaseDir(properties.getProperty("baseDir"))
                    .setParent(properties.getProperty("parent"))
                    .setEntity(properties.getProperty("entity"))
                    .setMapper(properties.getProperty("mapper"))
                    .setService(properties.getProperty("service"))
                    .setServiceImpl(properties.getProperty("serviceImpl"))
                    .setController(properties.getProperty("controller"));

        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    private String baseDir;
    private String parent;
    private String entity;
    private String mapper;
    private String service;
    private String serviceImpl;
    private String controller;

    public static TemplateConfig getInstance() {
        return TemplateConfig.templateConfig;
    }
}
